package badugaclient;

/**
 * @author Wojtek N., Kamil M.
 * @version 0.7
 * Class which bunch of setters and getters.
 * It contains all possible informations about player(s).
 */
public class PlayerInfo 
{
		private String host;
		private int connectionPort;
		private String info;
		private String action;
		private String content;
		private String sentToServer;

		private String myID;
		private String allPlayers;
		private String startingTokens;
		private String table;
		private String smallBlind;
		private String bigBlind;
		private String[] hand = new String[4];
		
		private String myBet;
		private int imyBet;
		private String myRaise;
		private int myTokens;
		private String cardsToChange = "";
		private boolean betted = true;
		private boolean raised = false;
		
		private String dealerID;
		private String smallID;
		private String bigID;
		private String betRound = "0";
		private int currentTopBet;
		private String playersID;
		private String playersBet;
		private String playersTokens;
		private String playersCardChange;
		private int howManyWinners;
		private String looserID;
		private String winnerID;
		private String winnersID;
		private String winningAmount;
		
		
		public String toString(String s)
		{
			String full = "";
			String rank = s.substring(0, 1);
			String suit = s.substring(1, 2);
			switch(rank)
			{
				case "A":
					full += "Ace of ";	break;
				case "T":
					full += "10 of ";	break;
				case "J":
					full += "Jack of ";	break;
				case "Q":
					full += "Queen of ";break;
				case "K":
					full += "King of ";	break;
			}
			
			switch(suit)
			{
				case "h":
					full += "hearts";	break;
				case "s":
					full += "spades";	break;
				case "d":
					full += "diamonds";	break;
				case "c":
					full += "clubs";	break;
			}
			return full;
		}
		
		/*
		 * ***************************	Setters section.	***************************
		 */
		public void defaultState()
		{
			this.betRound = "0";
			this.cardsToChange = "";
			this.betted = true;
			this.raised = false;
			this.currentTopBet = 0;
			this.imyBet = 0;
			
		}
		public void setStartingParam(String inFromServer) 
		{
			table = inFromServer.substring(0, 1);
			myID = inFromServer.substring(6, 7);
			allPlayers = inFromServer.substring(7, 8);
			startingTokens = inFromServer.substring(8, 11);
			bigBlind = inFromServer.substring(11, 13);
			smallBlind = inFromServer.substring(13, 15);
			myTokens = Integer.parseInt(startingTokens);
			
		}
		public void setHand(String inFromServer)
		{
			for(int i=0; i<7; i+=2)
			{
				hand[i] = inFromServer.substring(7+i,9+i);
			}
		}
		public void setSmallID(String smallID) 
		{
			if(smallID.equals(myID))
			{
				myTokens = Integer.parseInt(startingTokens) - Integer.parseInt(smallBlind);
				myBet = smallBlind;
			}
			this.smallID = smallID;
		}
		public void setBigID(String bigID)
		{
			if(bigID.equals(myID))
			{
				myTokens = Integer.parseInt(startingTokens) - Integer.parseInt(bigID);
				myBet = bigBlind;
			}
			this.bigID = bigID;
		}
		public void setBetRound(String inFromServer)
		{
			if(!(this.betRound.equals(inFromServer)))
			{
				this.betRound = inFromServer;
				betted = false;				
			}
			
		}
		
		public void setBetted(boolean betted) {
			this.betted = betted;
		}

		public void setRaised(boolean raised) {
			this.raised = raised;
		}

		public void resetSelection()
		{
			cardsToChange="";
		}
		public void setHost(String host) 
		{
			this.host = host;
		}
		public void setConnectionPort(int connectionPort)
		{
			this.connectionPort = connectionPort;
		}
		public void setInfo(String info)
		{
			this.info = info;
		}
		public void setAction(String action)
		{
			this.action = action;
		}
		public void setContent(String content) 
		{
			this.content = content;
		}
		public void setSentToServer(String sentFromUser)
		{
			this.sentToServer = sentFromUser;
		}
		public void setCardsToChange(String cardsToChange, int place)
		{
			if(place>this.cardsToChange.length())
			{
				for(int i=0; i<place; i++)
				{
					if(this.cardsToChange.substring(i, i+1) == null)
					{
						this.cardsToChange += "F";
					}
				}
			}
			else
			{
				this.cardsToChange += cardsToChange;
			}
		}
		public void setMyTokens(int tokens)
		{
			this.myTokens = tokens;
		}
		public void setMyTokensAfterAll(int add)
		{
			myTokens += add;
		}
		public void setMyBet(String myBet)
		{
			this.myBet = myBet;
		}
		public void setMyBetInt(String myBet) 
		{
			this.imyBet = Integer.parseInt(myBet);
		}
		public void setMyRaise(String myRaise)
		{
			this.myRaise = myRaise;
		}
		public void setDealerID(String dealerID) 
		{
			this.dealerID = dealerID;
		}
		public void setCurrentTopBet(String currentTopBet) 
		{
			this.currentTopBet = Integer.parseInt(currentTopBet);
		}
		public void setPlayersID(String playersID)
		{
			this.playersID = playersID;
		}
		public void setPlayersBet(String playersBet)
		{
			this.playersBet = playersBet;
		}
		public void setPlayersTokens(String playersTokens)
		{
			this.playersTokens = playersTokens;
		}
		public void setPlayersCardChange(String playersCardChange)
		{
			this.playersCardChange = playersCardChange;
		}
		public void setMyID(String myID) 
		{
			this.myID = myID;
		}
		public void setAllPlayers(String allPlayers) 
		{
			this.allPlayers = allPlayers;
		}
		public void setStartingTokens(String startingTokens) 
		{
			this.startingTokens = startingTokens;
		}
		public void setTable(String table) 
		{
			this.table = table;
		}
		public void setSmallBlind(String smallBlind) 
		{
			this.smallBlind = smallBlind;
		}
		public void setBigBlind(String bigBlind) 
		{
			this.bigBlind = bigBlind;
		}
		public void setHowManyWinners(String inFromServer)
		{
			inFromServer = inFromServer.split("|")[0];
			this.howManyWinners = inFromServer.substring(6).length();
		}
		public void setLooserID(String looserID) 
		{
			this.looserID = looserID;
		}
		public void setWinnerID(String inFromServer)
		{
			this.winnerID = inFromServer.substring(6, 7);
		}
		public void setWinnersID(String inFromServer)
		{
			inFromServer = inFromServer.split("|")[0];
			this.winnersID = inFromServer.substring(6);
		}
		public void setWinningAmount(String inFromServer)
		{
			inFromServer = inFromServer.split("|")[1];
			this.winningAmount = inFromServer;
		}
		
		/*
		 * ***************************	Getters section.	***************************
		 */
		public String getHandForView()
		{
			String temp = "";
			for(int i=0; i<hand.length; i++)
			{
				temp += toString(hand[i]);
			}
			
			return temp;
		}
		public String getHand()
		{
			String temp = "";
			for(int i=0; i<hand.length; i++)
			{
				temp += hand[i];
			}
			
			return temp;
		}
		
		public boolean isBetted() {
			return betted;
		}

		public boolean isRaised() {
			return raised;
		}

		public int getCall()
		{
			return (currentTopBet - imyBet);
		}
		public String getCard(int i)
		{
			return hand[i];
		}
		public String getHost()
		{
			return host;
		}
		
		public int getConnectionPort() 
		{
			return connectionPort;
		}
		public String getInfo()
		{
			return info;
		}
		public String getAction()
		{
			return action;
		}
		public String getContent() 
		{
			return content;
		}
		public String getSentToServer() 
		{
			return sentToServer;
		}
		public String getMyID()
		{
			return myID;
		}
		public String getAllPlayers()
		{
			return allPlayers;
		}
		public String getStartingTokens()
		{
			return startingTokens;
		}
		public String getTable()
		{
			return table;
		}
		public String getSmallBlind() 
		{
			return smallBlind;
		}
		public String getBigBlind() 
		{
			return bigBlind;
		}
		public String getCardsToChange()
		{
			return cardsToChange;
		}
		public String getMyBet()
		{
			return myBet;
		}
		public String getMyRaise() 
		{
			return myRaise;
		}
		public int getMyTokens()
		{
			return myTokens;
		}
		public int getMyBetInt() 
		{
			return imyBet;
		}
		public String getDealerID() 
		{
			return dealerID;
		}
		public String getSmallID() 
		{
			return smallID;
		}
		public String getBigID()
		{
			return bigID;
		}
		public String getBetRound()
		{
			return betRound;
		}
		public int getCurrentTopBet() 
		{
			return currentTopBet;
		}
		public String getPlayersID()
		{
			return playersID;
		}
		public int getPlayersBet() 
		{
			return Integer.parseInt(playersBet);
		}
		public String getPlayersTokens()
		{
			return playersTokens;
		}
		public String getPlayersCardChange() 
		{
			return playersCardChange;
		}
		public int getHowManyWinners() 
		{
			return howManyWinners;
		}
		public String getLooserID() 
		{
			return looserID;
		}
		public String getWinnerID()
		{
			return winnerID;
		}
		public String getWinnersID()
		{
			return winnersID;
		}
		public String getWinningAmount() 
		{
			return winningAmount;
		}
	
		
}